import ethwallet from 'ethereumjs-wallet'
import Web3 from 'web3'
const web3 = new Web3(Web3.givenProvider || "http://111.229.103.33")
// 通过私钥获取公钥
const getPublicAddressByPrivateKey = (privateKey) => {
    const priKey = Buffer(privateKey, "hex")
    const wallet = ethwallet.fromPrivateKey(priKey)
    const publicAddress = wallet.getAddressString()

    return publicAddress

}


const signMessage = (message,privateKey)=>{
    const signature = web3.eth.accounts.sign(message,"0x"+privateKey)
    return signature.signature 
}


export {
    getPublicAddressByPrivateKey,
    signMessage
}